// 4.0 获取菜单数据
import axios from "../../utils/axios"

export default {
    namespaced: true,
    state() {
        return {
            adminList: []
        }
    },
    mutations: {
        saveAdminListMutations(state, list) {
            console.log("saveAdminListMutations执行了")
            console.log(list)
            state.adminList = list
        }
    },
    actions: {
        getAdminListActions({commit},pagesinfo) {
            console.log("getAdminListActions执行了")
            axios({
                method: 'GET',
                url: '/api/userlist',
                params:pagesinfo
            }).then( response => {
                // 关联上下级菜单数据
                console.log(response)
                // let pmenus = response.list.filter(item => item.pid === 0)
                // pmenus.forEach(pitem => {
                //     pitem.children = []
                //     response.list.forEach(item => {
                //         if (item.pid === pitem.id) {
                //             pitem.children.push(item)
                //         }
                //     })
                // })

                commit('saveAdminListMutations', response.list)
                
            })
        },
        getAdminCountActions({commit}){
           
        }
        
    },
    getters: {}
}


